package hu.stud.uszeged.inf.prf.prftrac.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
public class User implements Serializable
{
	private static final long serialVersionUID = 5163265357378138669L;
	
	private String nickName;
	private String password;
	private String name;
	private String role;
	@ManyToOne
	@Fetch(FetchMode.JOIN)
	private Project project;
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	protected Long id;
	
	public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
	public String getNickName() {
		return nickName;
	}
	public void setNickName(String nickName) {
		this.nickName = nickName;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getPassword() {
		return password;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getRole() {
		return role;
	}
	public void setRole(String role) {
		this.role = role;
	}
	
	public Project getProject() {
		return project;
	}
	public void setProject(Project project) {
		this.project = project;
	}
    
    @Override
	public String toString() {
		return "User [ID=" + id + ", UserName=" + name + ", nickName="
				+ nickName + ", project=" + project + ", role=" + role + "]";
	}
    
    public List<Project> getProjectAsList() {
    	ArrayList<Project> l = new ArrayList<Project>();
    	l.add(project);
    	return l;
    }

}
